package com.ztman.rxjava.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by YJH on 2017/11/30.
 * 功能：弹出土司的工具类
 */

public class ToastPop {

    public static Context tContext;
    private ToastPop(){}

    public static void registerForToast(Context context){
        tContext = context.getApplicationContext();

    }

    private static void checkBeforeExecute(){
        if(null == tContext){
            throw new NullPointerException("NullPointerException-Repair : initial call ToastPop.registerForToast(Context context) in your Application, please.");
        }
    }

    public static void showShort(String msg){
        checkBeforeExecute();
        Toast.makeText(tContext, msg, Toast.LENGTH_SHORT).show();
    }

    public static void showLong(String msg){
        checkBeforeExecute();
        Toast.makeText(tContext, msg, Toast.LENGTH_LONG).show();
    }

}
